package top.tsyz.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import top.tsyz.entity.Payment;
import top.tsyz.service.IPaymentService;

import java.util.List;

/**
 * PaymentController控制器
 */
@RestController
@RequestMapping("/api/payments")
@Api(tags = "Payment管理接口")
public class PaymentController {

    @Autowired
    private IPaymentService ipaymentservice;

    @GetMapping("/list")
    @ApiOperation("获取所有Payment")
    public List<Payment> list() {
        return ipaymentservice.list();
    }

    @GetMapping("/{id}")
    @ApiOperation("根据ID获取Payment")
    public Payment getById(@PathVariable Long id) {
        return ipaymentservice.getById(id);
    }

    @PostMapping
    @ApiOperation("新增Payment")
    public boolean save(@RequestBody Payment payment) {
        return ipaymentservice.save(payment);
    }

    @PutMapping
    @ApiOperation("更新Payment")
    public boolean update(@RequestBody Payment payment) {
        return ipaymentservice.updateById(payment);
    }

    @DeleteMapping("/{id}")
    @ApiOperation("删除Payment")
    public boolean delete(@PathVariable Long id) {
        return ipaymentservice.removeById(id);
    }
}
